<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

    <ui:define name="head">
        <link type="text/css" href="#{request.contextPath}/UI/epss/epss.css" rel="stylesheet"/>
        <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                    else
                        event.srcElement.click();
                }
            }
            function actSelect(obj,pageName) {
                var pkid=obj;
                var sfeature = "dialogwidth:1100px;dialogheight:600px;center:yes;location:no;help:no;resizable:no;scroll:no;status:no";
                var arg = new Object();
                arg.doType = "select";
                if (pageName=="Sub_Detail"){
                    var rtn =dialog("../cttd/itemMng_Cstpl_Sub.xhtml?strType=2&amp;strSubCttPkid="+pkid+"",arg,sfeature);
                }else if(pageName=="Attachment"){
                    var rtn = window.open("../attachment/attachment_Mng.jsp?strType=1&amp;strPkid="+pkid+"",
                            'popupwindow',
                            'height = 300,width = 450,location = no,resizable = no,scrollbars = no,status = no,toolbar = no,top = 100');
                }
            }
        </script>
    </ui:define>
    <ui:define name="content">
        <h:form id="form" enctype="multipart/form-data">
            <p:growl id="msgs" showDetail="true"/>
            <p:focus for="id"/>
            <h:panelGrid id="pgCondition" style="width: 100%">
                <h:panelGrid columns="7">
                    <h:outputLabel value="合同编号：" for="id"/>
                    <p:inputText id="id" value="#{cttHAction.rowCttH.id}"
                                 readonly="#{cttHAction.styleModel.disabled_Flag}"
                                 style="#{cttHAction.styleModel.disabled_Style};"/>
                    <p:commandButton id="autoSetIdBtn" icon="ui-icon-plus"
                                     action="#{cttHAction.setMaxNoPlusOne('2')}"
                                     update="id"
                                     disabled="#{cttHAction.styleModel.disabled_Flag}"
                                     style="#{cttHAction.styleModel.disabled_Style};height:20px">
                    </p:commandButton>
                    <h:outputLabel value="合同名称：" for="cttName"/>
                    <p:inputText id="cttName" value="#{cttHAction.rowCttH.name}"
                                 readonly="#{cttHAction.styleModel.disabled_Flag}"
                                 style="#{cttHAction.styleModel.disabled_Style};"/>
                    <h:outputLabel value="备注内容：" for="note"/>
                    <p:inputText id="note" value="#{cttHAction.rowCttH.note}"/>
                </h:panelGrid>
                <h:panelGrid columns="8">
                    <h:outputLabel value="签订日期：  " for="signDate"/>
                    <p:inputText id="signDate" value="#{cttHAction.rowCttH.signDate}"
                                 onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
                                 disabled="#{cttHAction.styleModel.disabled_Flag}"
                                 style="#{cttHAction.styleModel.disabled_Style};width:160px"/>
                    <h:outputLabel value="开始时间：" for="cttStartDate"/>
                    <p:inputText id="cttStartDate" value="#{cttHAction.rowCttH.cttStartDate}"
                                 onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
                                 disabled="#{cttHAction.styleModel.disabled_Flag}"
                                 style="#{cttHAction.styleModel.disabled_Style};"/>
                    <h:outputLabel value="截止时间：" for="cttEndDate"/>
                    <p:inputText id="cttEndDate" value="#{cttHAction.rowCttH.cttEndDate}"
                                 onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
                                 disabled="#{cttHAction.styleModel.disabled_Flag}"
                                 style="#{cttHAction.styleModel.disabled_Style};"/>
                    <h:outputLabel value="结束标志：" for="endFlag"/>
                    <p:selectOneMenu id="endFlag" value="#{cttHAction.rowCttH.endFlag}"
                                     disabled="#{cttHAction.styleModel.disabled_Flag}"
                                     style="#{cttHAction.styleModel.disabled_Style};">
                        <f:selectItems value="#{flowControlAction.endFlagList}"/>
                    </p:selectOneMenu>
                </h:panelGrid>
                <h:panelGrid columns="4">
                    <h:outputLabel value="签订甲方：" for="signPartA"/>
                    <p:selectOneMenu id="signPartA" value="#{cttHAction.rowCttH.signPartA}"
                                     disabled="#{cttHAction.styleModel.disabled_Flag}"
                                     style="#{cttHAction.styleModel.disabled_Style};">
                        <f:selectItems value="#{commonAction.customerlist}"/>
                    </p:selectOneMenu>
                    <h:outputLabel value="签订乙方：" for="signPartB"/>
                    <p:selectOneMenu id="signPartB" value="#{cttHAction.rowCttH.signPartB}"
                                     disabled="#{cttHAction.styleModel.disabled_Flag}"
                                     style="#{cttHAction.styleModel.disabled_Style};">
                        <f:selectItems value="#{commonAction.customerlist}"/>
                    </p:selectOneMenu>
                </h:panelGrid>
                <h:panelGrid columns="6">
                    <p:commandButton id="qryBtn" value="查询"
                                     action="#{cttHAction.onQueryAction('2','Mng')}"
                                     update="pdt,msgs">
                    </p:commandButton>
                    <p:commandButton id="resetBtn" value="重置"
                                     action="#{cttHAction.resetAction}"
                                     update="pgCondition,msgs">
                    </p:commandButton>
                    <p:commandButton id="submitBtn"
                                     value="#{cttHAction.strSubmitType eq 'Add'?'提交（增加）':
                                               cttHAction.strSubmitType eq 'Upd'?'提交（更新）':
                                               cttHAction.strSubmitType eq 'Del'?'提交（删除）':'提交'}"
                                     action="#{cttHAction.onClickForMngAction('2')}"
                                     update="pdt,msgs,pgCondition"
                                     rendered="#{cttHAction.rowSelectedFlag eq 'true'?'false':'true'}">
                    </p:commandButton>
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="/images/ajaxloading.gif"/>
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value=""/>
                        </f:facet>
                    </p:ajaxStatus>
                    <p:commandButton id="endInputBtn" value="录入完成"
                                     action="#{cttHAction.onClickForPowerAction('MngPass')}"
                                     update="pgCondition,pdt,msgs"
                                     rendered="#{cttHAction.rowSelectedFlag}">
                    </p:commandButton>
                    <p:commandButton id="startInputBtn" value="录入未完"
                                     action="#{cttHAction.onClickForPowerAction('MngFail')}"
                                     update="pgCondition,pdt,msgs"
                                     rendered="#{cttHAction.rowSelectedFlag}">
                    </p:commandButton>
                </h:panelGrid>
            </h:panelGrid>
            <p:contextMenu for="pdt">
                <p:menuitem value="选择" icon="ui-icon-plus"
                            actionListener="#{cttHAction.selectRecordAction('Mng','Sel','2')}"
                            update="pdt,msgs,pgCondition">
                </p:menuitem>
                <p:menuitem value="更新" icon="ui-icon-arrowrefresh-1-w"
                            actionListener="#{cttHAction.selectRecordAction('Mng','Upd','2')}"
                            update="pdt,msgs,pgCondition">
                </p:menuitem>
                <p:menuitem value="删除" icon="ui-icon-close"
                            actionListener="#{cttHAction.selectRecordAction('Mng','Del','2')}"
                            update="pdt,msgs,pgCondition">
                </p:menuitem>
                <p:menuitem value="详细内容" icon="ui-icon-search"
                            oncomplete="actSelect(DtInitSubcttList.selection,'Sub_Detail')" >
                </p:menuitem>
                <p:menuitem value="附件" icon="ui-icon-search"
                            oncomplete="actSelect(DtInitSubcttList.selection,'Attachment')" >
                </p:menuitem>
            </p:contextMenu>
            <p:dataTable id="pdt" style="width:100%;"
                         value="#{cttHAction.rowCttHList}"
                         var="record"
                         rowKey="#{record.pkid}"
                         selection="#{cttHAction.rowCttHSelected}"
                         selectionMode="single"
                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
                         {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         paginator="true"
                         paginatorPosition="bottom"
                         rows="15"
                         rowIndexVar="row"
                         rowsPerPageTemplate="500,200,90,45,30,15"
                         emptyMessage="数据记录为空..."
                         widgetVar="DtInitSubcttList"
                         rowStyleClass="#{record.statusFlag eq null? null:'rowDoneStyle'}"
                         scrollable="true"
                         scrollHeight="410">
                <p:column headerText="序号" style="width:30px">
                    <h:outputText value="#{row + 1}"/>
                </p:column>
                <p:column headerText="所属编号" style="width:140px;text-align:center">
                    <h:outputText value="#{cttHAction.getEsInitCttByPkId(record.parentPkid).id}"/>
                </p:column>
                <p:column headerText="分包合同号" style="width:120px;text-align:center">
                    <h:outputText value="#{record.id}"/>
                </p:column>
                <p:column headerText="分包合同名" style="width:200px;text-align:left">
                    <h:outputText value="#{record.name}"/>
                </p:column>
                <p:column headerText="签订甲方" style="width:150px;text-align:left">
                    <h:outputText value="#{commonAction.getCustNameByCustIdFromList(record.signPartA)}"/>
                </p:column>
                <p:column headerText="签订乙方" style="width:150px;text-align:left">
                    <h:outputText value="#{commonAction.getCustNameByCustIdFromList(record.signPartB)}"/>
                </p:column>
                <p:column headerText="状态标志" style="width:66px;text-align:center">
                    <h:outputText value="#{flowControlAction.getLabelByValueInStatusFlaglist(record.statusFlag)}"/>
                </p:column>
                <p:column headerText="原因" style="width:66px;text-align:center">
                    <h:outputText value="#{flowControlAction.getLabelByValueInPreStatusFlaglist(record.preStatusFlag)}"/>
                </p:column>
                <p:column headerText="开始时间" style="width:66px;text-align:center">
                    <h:outputText value="#{record.cttStartDate}"/>
                </p:column>
                <p:column headerText="截止时间" style="width:66px;text-align:center">
                    <h:outputText value="#{record.cttEndDate}"/>
                </p:column>
                <p:column headerText="结束标志" style="width:66px;text-align:center">
                    <h:outputText value="#{flowControlAction.getLabelByValueInEndFlagList(record.endFlag)}"/>
                </p:column>
                <p:column headerText="签订日期" style="width:66px;text-align:center">
                    <h:outputText value="#{record.signDate}"/>
                </p:column>
                <p:column headerText="备注内容" style="width:200px;text-align:left">
                    <h:outputText value="#{record.note}"/>
                </p:column>
            </p:dataTable>
        </h:form>
    </ui:define>
</ui:composition>